﻿<cfsilent>
<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		sql = "SELECT a.institute_id,
					   a.institute_name 
				FROM t_institute a 
				WHERE a.institute_id = :InstituteID ";
				
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="InstituteID", value=event.getArg("DepID") , cfsqltype="cf_sql_varchar" );
		
		rs_department = queryObj.execute( sql=sql ).getResult();

		/*需要设置的课程列表*/
	
		sql = "SELECT c.cid,c.course_code,c.course_name 
				FROM t_course c 
				WHERE c.abandon = '0' 
					  AND NOT EXISTS(
						  SELECT cw.cid 
						  FROM t_course_workload cw 
						  WHERE cw.cid= c.cid
					  ) 
					  AND c.institute_id = :Institute 
				ORDER BY c.course_name ASC";
				
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="Institute", value=rs_department.institute_id , cfsqltype="cf_sql_varchar" );
		
		rs_needSet = queryObj.execute( sql=sql ).getResult();	

		/*已经设置的课程列表*/
	
		sql = "SELECT c.cid,c.course_code,c.course_name 
				FROM t_course c 
				WHERE c.abandon = '0' 
					  AND EXISTS(
						  SELECT cw.cid 
						  FROM t_course_workload cw 
						  WHERE cw.cid= c.cid
					  ) 
					  AND c.institute_id = :Institute 
				ORDER BY c.course_name ASC";
				
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="Institute", value=rs_department.institute_id , cfsqltype="cf_sql_varchar" );
		
		rs_haveSet = queryObj.execute( sql=sql ).getResult();	

		event.setArg("pageTitle", "教学运行基础数据 -课程系数维护 - 工作量系数设置 - " & rs_department.institute_name);

		passArgs = structNew();
		structInsert(passArgs, "DepID", rs_department.institute_id, true);

		currentTab = event.getArg("TabID", "labNeedset");

		/* 搜索课程 */
		keyword = event.getArg("Keywords");
		
		rs_search = queryNew("cid");
		
		if ( len(keyword) ) {
			
			sql = "SELECT 
					c.cid,c.course_code,c.course_name
					FROM t_course c
					WHERE 
						c.institute_id = :depId 
						AND(
							c.course_code LIKE :condition 
							OR 
							c.course_name LIKE :condition 
           		 		)
					ORDER BY c.course_name";
					
			queryObj = new query( datasource=application.dnsSlave,maxRows=20 );
			queryObj.addParam( name="condition", value=keyword&"%", cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="depId", value=rs_department.institute_id, cfsqltype="cf_sql_varchar" );
			
			rs_search = queryObj.execute( sql=sql ).getResult();
			
			currentTab = "labSearch";
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat"> <a class="uiButton" href="<cfoutput>#buildURL('courseWorkLoad')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">其它学院</span></a> </div>
			<div>
				<h2 class="uiHeaderTitle"> <i class="uiHeaderImage img icon16x16 card"></i><cfoutput>#rs_department.institute_name#</cfoutput>课程工作量设置列表 </h2>
			</div>
		</div>
	</div>
</div>
<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables"> <span <cfif currentTab eq "labNeedset">class="active"</cfif> id="labNeedset" tabTarget="Needset">未设置课程</span> <span <cfif currentTab eq "labHaveset">class="active"</cfif> id="labHaveset" tabTarget="Haveset">已设置课程</span> <span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索</span> </div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				<div id="Needset" class="tabContent">
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="20"></td>
								<td width="80">课程号</td>
								<td width="140">课程</td>
								<td>双语系数</td>
								<td>实践系数</td>
								<td>分配比例</td>
								<td>编制分类</td>
								<td>理论公式</td>
								<td>实践公式</td>
								<td width="20"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_needSet" >
								<cfset row ++ />
							
                                <cfset sql = "SELECT c.cid,c.lang_weight,
													   c.prac_weight,c.work_divide,
													   a.type_name,b.fun_id fun_id1,
													   b.fun_name fun_name1,d.fun_id fun_id2,
													   d.fun_name fun_name2 
												FROM t_course_workload c 
													 INNER JOIN t_hr_workload a ON a.hrt = c.hrt 
													 INNER JOIN t_workload_fun b ON b.fun_id = c.theory_fun 
													 INNER JOIN t_workload_fun d ON d.fun_id = c.practice_fun 
												WHERE c.cid = :CourseID " />
                                    
								<cfset queryObj = new query( datasource=application.dnsSlave )/>
                                <cfset queryObj.addParam( name="CourseID", value=rs_needSet.cid, cfsqltype="cf_sql_varchar" )/>
                                <cfset rs_CourseWorkLoads = queryObj.execute( sql=sql ).getResult()/>
								<cfset structInsert(passArgs, "CID", rs_needSet.cid, true) />
                                
								<tr class="editRows <cfif event.getArg('CID') eq rs_needSet.cid> lastEdited</cfif>" rowid="<cfoutput>#rs_needSet.cid#</cfoutput>">
									<td><cfoutput>#numberFormat(row, '0_')#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_needSet.course_code#</cfoutput></span></td>
									<td><cfoutput>#rs_needSet.course_name#</cfoutput></td>
									<td><cfif rs_CourseWorkLoads.recordCount>
											<cfoutput>#rs_CourseWorkLoads["lang_weight"][1]#</cfoutput>
										</cfif></td>
									<td><cfif rs_CourseWorkLoads.recordCount>
											<cfoutput>#rs_CourseWorkLoads["prac_weight"][1]#</cfoutput>
										</cfif></td>
									<td><cfif rs_CourseWorkLoads.recordCount>
											<cfoutput>#rs_CourseWorkLoads["work_divide"][1]#</cfoutput>
										</cfif></td>
									<td><cfif rs_CourseWorkLoads.recordCount>
											<cfoutput>#rs_CourseWorkLoads["type_name"][1]#</cfoutput>
											<cfelse>
											未设置
										</cfif></td>
									<td><cfif rs_CourseWorkLoads.recordCount>
											<cfoutput>#rs_CourseWorkLoads["fun_name1"][1]#</cfoutput>
											<cfelse>
											未设置
										</cfif></td>
									<td><cfif rs_CourseWorkLoads.recordCount>
											<cfoutput>#rs_CourseWorkLoads["fun_name2"][1]#</cfoutput>
											<cfelse>
											未设置
										</cfif></td>
									<td><a href="<cfoutput>#BuildURL("courseWorkLoadInstitute",passArgs)#</cfoutput>" class="stat edit"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
				</div>
				<div id="Haveset" class="tabContent">
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="20"></td>
								<td width="80">课程号</td>
								<td width="140">课程</td>
								<td>双语系数</td>
								<td>实践系数</td>
								<td>分配比例</td>
								<td>编制分类</td>
								<td>理论公式</td>
								<td>实践公式</td>
								<td width="20"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_haveSet"  >
								<cfset row ++ />
							
                                <cfset sql = "SELECT c.cid,c.lang_weight,
													   c.prac_weight,c.work_divide,
													   a.type_name,b.fun_id fun_id1,
													   b.fun_name fun_name1,d.fun_id fun_id2,
													   d.fun_name fun_name2 
												FROM t_course_workload c 
													 INNER JOIN t_hr_workload a ON a.hrt = c.hrt 
													 INNER JOIN t_workload_fun b ON b.fun_id = c.theory_fun 
													 INNER JOIN t_workload_fun d ON d.fun_id = c.practice_fun 
												WHERE c.cid = :CourseID " />
                                    
								<cfset queryObj = new query( datasource=application.dnsSlave )/>
                                <cfset queryObj.addParam( name="CourseID", value=rs_haveSet.cid, cfsqltype="cf_sql_varchar" )/>
                                <cfset rs_CourseHave = queryObj.execute( sql=sql ).getResult()/>
								<cfset structInsert(passArgs, "CID", rs_haveSet.cid, true) />
								<tr class="editRows <cfif event.getArg('CID') eq rs_haveSet.cid> lastEdited</cfif>" rowid="<cfoutput>#rs_haveSet.cid#</cfoutput>">
									<td><cfoutput>#numberFormat(row, '0_')#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_haveSet.course_code#</cfoutput></span></td>
									<td><cfoutput>#rs_haveSet.course_name#</cfoutput></td>
									<td><cfif rs_CourseHave.recordCount>
											<cfoutput>#rs_CourseHave["lang_weight"][1]#</cfoutput>
										</cfif></td>
									<td><cfif rs_CourseHave.recordCount>
											<cfoutput>#rs_CourseHave["prac_weight"][1]#</cfoutput>
										</cfif></td>
									<td><cfif rs_CourseHave.recordCount>
											<cfoutput>#rs_CourseHave["work_divide"][1]#</cfoutput>
										</cfif></td>
									<td><cfif rs_CourseHave.recordCount>
											<cfoutput>#rs_CourseHave["type_name"][1]#</cfoutput>
											<cfelse>
											未设置
										</cfif></td>
									<td><cfif rs_CourseHave.recordCount>
											<cfoutput>#rs_CourseHave["fun_name1"][1]#</cfoutput>
											<cfelse>
											未设置
										</cfif></td>
									<td><cfif rs_CourseHave.recordCount>
											<cfoutput>#rs_CourseHave["fun_name2"][1]#</cfoutput>
											<cfelse>
											未设置
										</cfif></td>
									<td><a href="<cfoutput>#BuildURL("courseWorkLoadInstitute",passArgs)#</cfoutput>" class="stat edit"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
				</div>
				<div id="Search" class="tabContent">
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('courseByDepartment')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						<input type="hidden" name="DepID" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
						<div class="label"> <b>课程或课程号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					<cfif rs_search.recordCount>
						<cfset structInsert(passArgs,"Keywords",keyword,true) />
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="20"></td>
									<td width="80">课程号</td>
									<td width="140">课程</td>
									<td>双语系数</td>
									<td>实践系数</td>
									<td>分配比例</td>
									<td>编制分类</td>
									<td>理论公式</td>
									<td>实践公式</td>
									<td width="20"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_search" >
									<cfset row ++ />
							
                                    <cfset sql = "SELECT c.cid,c.lang_weight,
													   c.prac_weight,c.work_divide,
													   a.type_name,b.fun_id fun_id1,
													   b.fun_name fun_name1,d.fun_id fun_id2,
													   d.fun_name fun_name2 
												FROM t_course_workload c 
													 INNER JOIN t_hr_workload a ON a.hrt = c.hrt 
													 INNER JOIN t_workload_fun b ON b.fun_id = c.theory_fun 
													 INNER JOIN t_workload_fun d ON d.fun_id = c.practice_fun 
												WHERE c.cid = :CourseID " />
                                    
									<cfset queryObj = new query( datasource=application.dnsSlave )/>
                                    <cfset queryObj.addParam( name="CourseID", value=rs_search.cid, cfsqltype="cf_sql_varchar" )/>
                                    <cfset rs_CourseSearch = queryObj.execute( sql=sql ).getResult()/>
									<cfset structInsert(passArgs, "CID", rs_search.cid, true) />
									<tr class="editRows <cfif event.getArg('CID') eq rs_search.cid> lastEdited</cfif>" rowid="<cfoutput>#rs_search.cid#</cfoutput>">
										<td><cfoutput>#numberFormat(row, '0_')#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_search.course_code#</cfoutput></span></td>
										<td><cfoutput>#rs_search.course_name#</cfoutput></td>
										<td><cfif rs_CourseSearch.recordCount>
												<cfoutput>#rs_CourseSearch["lang_weight"][1]#</cfoutput>
											</cfif></td>
										<td><cfif rs_CourseSearch.recordCount>
												<cfoutput>#rs_CourseSearch["prac_weight"][1]#</cfoutput>
											</cfif></td>
										<td><cfif rs_CourseSearch.recordCount>
												<cfoutput>#rs_CourseSearch["work_divide"][1]#</cfoutput>
											</cfif></td>
										<td><cfif rs_CourseSearch.recordCount>
												<cfoutput>#rs_CourseSearch["type_name"][1]#</cfoutput>
												<cfelse>
												未设置
											</cfif></td>
										<td><cfif rs_CourseSearch.recordCount>
												<cfoutput>#rs_CourseSearch["fun_name1"][1]#</cfoutput>
												<cfelse>
												未设置
											</cfif></td>
										<td><cfif rs_CourseSearch.recordCount>
												<cfoutput>#rs_CourseSearch["fun_name2"][1]#</cfoutput>
												<cfelse>
												未设置
											</cfif></td>
										<td><a href="<cfoutput>#BuildURL("courseWorkLoadInstitute",passArgs)#</cfoutput>" class="stat edit"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					</cfif>
				</div>
			</div>
		</li>
	</ul>
</div>
